package milktea.servlet.cate;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import milktea.entity.CATEGORY;
import milktea.service.CATEGORYService;

/**
 * Servlet implementation class DoUserCate
 */
@WebServlet("/manage/admin_docateadd")
public class DoCateAdd extends HttpServlet {

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        int fid = Integer.parseInt(request.getParameter("parentId"));
        String name = request.getParameter("className");

        CATEGORY cate = new CATEGORY(0, name, fid);
        CATEGORYService.insert(cate);
        response.sendRedirect("admin_cateselect");


    }

}
